package com.server.llh.llhserverwork.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import com.llh.llhsuppliers.R;
import com.server.llh.llhserverwork.bean.Account;

import java.util.List;

/**
 * Created by ZTF on 2017-06-14.
 */

public class MyAccountAdapter extends BaseAdapter {
    Context context;
    List<Account.DataBean> accountList;
    public MyAccountAdapter(Context context, List<Account.DataBean> accountList){
        this.context=context;
        this.accountList=accountList;
    }

    @Override
    public int getCount() {
        if (accountList==null&&accountList.size()==0){
            return  0;
        }
        return accountList.size();
    }

    @Override
    public Object getItem(int position) {
        return accountList.get(position);
    }


    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        VierHolder h = new VierHolder();
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(
                    R.layout.list_pay_style_item, null);
            h.cardNoBalance = (TextView) convertView.findViewById(R.id.list_child_tv1);
            h.cardNoTxt = (TextView) convertView.findViewById(R.id.list_child_tv2);
            h.list_child_im1 = (ImageView) convertView.findViewById(R.id.list_child_im1);
            h.list_child_im2 = (ImageView) convertView.findViewById(R.id.list_child_im2);
            convertView.setTag(h);
        } else {
            h = (VierHolder) convertView.getTag();
        }
        Account.DataBean  payQuery= accountList.get(position);
        if (payQuery.getAcctype()== 1){
            h.cardNoTxt.setText("个人现金  " );
        }else if (payQuery.getAcctype()== 10){
            h.cardNoTxt.setText("个人虚拟" );
        }else if (payQuery.getAcctype()== 15){
            h.cardNoTxt.setText("机构虚拟" );
        }else if (payQuery.getAcctype()== 20){
            h.cardNoTxt.setText("个人押金" );
        }else if (payQuery.getAcctype()== 25){
            h.cardNoTxt.setText("机构押金" );
        }else if (payQuery.getAcctype()== 30||payQuery.getAcctype()== 35){
            h.cardNoTxt.setText("机构结算" );
        }else if (payQuery.getAcctype()== 38){
            h.cardNoTxt.setText("个人积分" );
        }else if (payQuery.getAcctype()== 40){
            h.cardNoTxt.setText("个人账户" );
        }else if (payQuery.getAcctype()== 0){
            if (payQuery.getCardName()!=null){
                h.cardNoTxt.setText(""+payQuery.getCardName() );
            }
        }  else {
            if (payQuery.getCardName()!=null){
                h.cardNoTxt.setText(""+payQuery.getCardName() );
            }
        }
        h.cardNoBalance.setText(""+payQuery.getBalance());
        return convertView;
    }

    class VierHolder {
        TextView cardNoBalance,cardNoTxt;
        ImageView list_child_im1,list_child_im2;
    }

}
